import React, { Component, PropTypes } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View
} from 'react-native';

/***
 * props的详解
 */

export default class PropsComponent extends Component {
  // 定义默认的props
  static defaultProps = {
    name: 'ww',
    age: 22,
  }

  // 检查所传递类型的准确性
  static propTypes = {
    name: PropTypes.string,
    age: PropTypes.number,
    //sex属性为必须传递
    sex: PropTypes.string.isRequired,
  }

  render() {
    return (
      <View>
        <Text style={{ fontSize: 20, backgroundColor: '#bdbdbd' }}>Hello props name:[{this.props.name}]</Text>
        <Text style={{ fontSize: 20, backgroundColor: '#bdbdbd' }}>Hello props age :[{this.props.age}]</Text>
        <Text style={{ fontSize: 20, backgroundColor: '#bdbdbd' }}>Hello props sex :[{this.props.sex}]</Text>
      </View>
    )
  }
}